package chatclient.netio;

import chatclient.netio.Perms;
import chatclient.netio.Event;
import chatclient.netio.ClientAttr;
import chatclient.netio.Attr;
import chatclient.netio.AttrList;




public class Member {

    public Member() {
        name = "null";
        attrs = new AttrList();
    }

    public Member(String s, AttrList attrlist) {
        name = s;
        attrs = attrlist;
    }

    public String getName() {
        return name;
    }

    public Perms getPerms() {
        try {
            return Perms.fromAttr(attrs.get(ClientAttr.PERMS));
        } catch (Exception exception) {
            return new Perms();
        }
    }

    public void setPerms(Perms perms) {
        try {
            attrs.set(perms.toAttr(ClientAttr.PERMS));
        } catch (Exception exception) {
        }
    }

    public String getProfile() {
        try {
            return attrs.get(ClientAttr.PROFILE).getString();
        } catch (Exception exception) {
            return null;
        }
    }

    public void setProfile(String s) {
        try {
            attrs.set(new ClientAttr(ClientAttr.PROFILE, s));
        } catch (Exception exception) {
        }
    }

    public Attr[] getMemberInfo() {
        return (Attr[]) attrs.toArray(ClientAttr.MEMBERINFO);
    }

    public void setMemberInfo(Attr aattr[]) {
        try {
            attrs.set(ClientAttr.MEMBERINFO, aattr);
        } catch (Exception exception) {
        }
    }

    public Attr[] getUserInfo() {
        return (Attr[]) attrs.toArray(ClientAttr.USERINFO);
    }

    public void setUserInfo(Attr aattr[]) {
        try {
            attrs.set(ClientAttr.USERINFO, aattr);
        } catch (Exception exception) {
        }
    }

    public AttrList getAttrs() {
        return attrs;
    }

    public void setAttrs(AttrList attrlist) {
        attrs = attrlist;
    }

    public Event getLastEvent() {
        return lastEvent;
    }

    public void setLastEvent(Event event) {
        lastEvent = event;
    }

    public boolean isMarked() {
        return marked;
    }

    public void setMarked(boolean flag) {
        marked = flag;
    }
    private String name;
    private AttrList attrs;
    private Event lastEvent;
    private boolean marked;
}
